﻿using Entitas;
/// <summary>
/// If an enemies HP reacehs 0 then we must destroy that Enemy Entity
/// </summary>
class EnemyKilledSystem : ICleanupSystem
{
    EnemyContext enemyContext;
    public EnemyKilledSystem(Contexts contexts)
    {
        enemyContext = contexts.enemy;
    }
    public void Cleanup()
    {
        foreach (var e in enemyContext.GetEntities())
        {
            if (e.hitPoint.value <= 0)
            {
                e.enemyHitPointListener.value[0].OnHitPoint(e, 0);
                e.baseView.value.DestoryView();
                e.Destroy();
            }
        }
    
       
    }
}
